/**
 * SEVAS - Swiss Electronic Vaccination Advisor Service / Agile Development
 *
 * $Id: Initializer.java 77 2010-09-19 19:31:48Z zimmr7@bfh.ch $
 */
package ch.bfh.sevas;

import java.util.List;

public class Initializer {

    public static Long initSEVAS() throws Exception {

        Controller controller = new Controller();

        Long id = 0L;

        try {
            List<Patient> patients = controller.findAllPatients();

            for (Patient patient : patients) {
                id = patient.getId();
            }

            if (id.longValue() == 0) {
                controller.create(new Patient("Zimmermann", "Lea", new DateConverter().convertReverse("20.05.2000"), 0, "756.9217.0769.85"));
                controller.create(new Patient("Mustermann", "Max", new DateConverter().convertReverse("01.08.2005"), 0, "123.5789.0567.22"));
                for (Patient patient : patients) {
                    id = patient.getId();
                }
            }

            return id;

        } finally {
            controller.cleanup();
        }
    }
}
